import { request } from '@gui-pkg/request';

const PROD = import.meta.env.PROD;
const PUBLIC_PATH:string = PROD ? import.meta.env.VITE_PUBLIC_PATH: '';

const Api = {
  Boundary: `${PUBLIC_PATH}/data/boundary.json`,  // 灌区边界
  Channel: `${PUBLIC_PATH}/data/channel.json`,  // 灌区渠道
  Street: `${PUBLIC_PATH}/data/street.json`,  // 新禹河街道
}

// 本地地图GeoJson数据，去除请求的一些参数
const requestOptions = {
  joinParamsToUrl: false,
  withToken: false,
  joinTime: false,
  joinPrefix: false,
  isTransformResponse: false,
};

// 灌区边界
export function getBoundaryJson() {
  return request.get({ url: Api.Boundary }, requestOptions);
}

// 灌区渠道
export function getChannelJson() {
  return request.get({ url: Api.Channel }, requestOptions);
}

// 新禹河街道
export function getStreetPolygonJson() {
  return request.get({ url: Api.Street }, requestOptions);
}
